# 使用CentOS 7作为基础镜像
FROM centos:7

LABEL version="centos7 v1"
LABEL "emill"="197772517@qq.com"
 
# 更新yum源
RUN yum makecache fast && yum -y update glibc    

# 安装常用软件
RUN yum install -y openssh-server vim tar wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof
# 初始化ssh登陆
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
RUN echo "RSAAuthentication yes" >> /etc/ssh/sshd_config
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config    
RUN echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config    

# 添加登录密钥
RUN mkdir -p /root/.ssh/
RUN echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC5DOrkZJrR\
afXc8zUh8eyZIrMUM3uCKCFtoEceUi00sprjYtRmF9Md17lAXlx+cLxziA\
DJ33eiAPZ+FbQZ8Pv6GLyjXsXY/TYhTpMfXXhcMrKkOMUMusZynbS5oDoY\
g1eS20iYoo9D86fBCrKjeISIuf1P945aa8ocgruA/zT/C1G1ppi3HguLT0\
y3hX1U2nvKjjbmvPTz1stvMfHGBoYEhXNlILnJXe+Uyj6MJ5VMStmaNBbq\
n7+edfUVPgxurYmmMU86nEwG8WrPbcIIyo+NXRpSfgmaJYztYz2KKsG4VP\
re7BjvT08Iowle2SHLlH7chPFhD3k11u8IHgijgcMAMqYqtuYrWQHhX3gQ\
VfqVTvTxmFhRjkxyy+BdF0EEnPEsTQnYwtstMssfysU+QJcZ7YyDUSocVq\
hvgYj95dXk95gLoA4emgFHrmexExN17zOKcP5fBOpTtR0gGnINyFWmiyaz\
aQdBo2pplESkADza+JGjmZXeAoBrDVLq3mNCJXM= 197772517@qq.com" >> /root/.ssh/authorized_keys

RUN yum clean all
 
# 启动sshd服务并且暴露22端口
RUN mkdir /var/run/sshd    

# 安装JDK
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
RUN yum clean all
 
# 设置JAVA_HOME环境变量
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk
 
# 安装Vim
RUN yum install -y vim

# 安装frp
RUN mkdir -p /home/frp
COPY ./frp /home/frp
RUN chmod +x /home/frp/start.sh

# 安装 nginx
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
WORKDIR /usr/local/src
ENV NG_VERSION=nginx-1.25.1
RUN yum -y install epel-release
RUN yum -y install wget
RUN wget http://nginx.org/download/$NG_VERSION.tar.gz && tar xzvf $NG_VERSION.tar.gz 
RUN yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel && yum install -y pcre-devel libxslt-devel gd-devel GeoIP GeoIP-devel GeoIP-data
RUN yum clean all 
RUN useradd -M -s /sbin/nologin nginx 
WORKDIR /usr/local/src/$NG_VERSION 
RUN ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module && make && make install
ADD index.html /usr/local/nginx/html 
VOLUME /usr/local/nginx/html 
ENV PATH /usr/local/nginx/sbin:$PATH 

# 工作目录
RUN mkdir /home/work
VOLUME /home/work
 
# 暴露22端口（SSH默认端口）
EXPOSE 22
 
# 启动SSH服务
CMD ["/home/frp/start.sh"]